package com.ideal.dto;

import com.ideal.enums.GlobalExceptionEnum;

/**
 * @Author songfz
 * @Description
 * @Date 2022/7/13
 */
public class ResultDto {

    private Integer code;

    private String msg;

    private Object data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public ResultDto(Object data) {
        this.data = data;
    }

    public ResultDto(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static ResultDto success(Object obj) {
        return new ResultDto(0,"success",obj);
    }

    public static ResultDto fail(String msg){
        return new ResultDto(600,msg,null);
    }

    public static ResultDto fail(GlobalExceptionEnum failEnum){
        return new ResultDto(failEnum.getCode(),failEnum.getMsg(),null);
    }
}
